<!DOCTYPE html>
<html>
<head>
    <title>修改住院信息--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="../Css/style.css"/>
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>


    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script>
        function oneValues() {
            var result;
            var url = window.location.search; //获取url中"?"符后的字串
            if (url.indexOf("?") != -1) {
                result = url.substr(url.indexOf("=") + 1);
            }
            return result;
        }

        // 这样调用：
        function findDept(result) {
            $.ajax({
                type: "GET",
                url: "/dept/findDept",
                dataType: "json",
                success: function (vo) {
                    let data = vo.list;

                    let str = "";
                    for (let i = 0; i < data.length; i++) {
                        if (result == data[i].deptId) {
                            str += "<option selected='selected'  value=\" " + data[i].deptId + "\" >" + data[i].deptName + "</option>\n"
                        } else {
                            str += "<option  value=\" " + data[i].deptId + "\" >" + data[i].deptName + "</option>\n"
                        }

                    }
                    $("#dept").html(str);

                },
            })

        }

        function findDoctor(result) {
            $.ajax({
                type: "GET",
                url: "/Doctor/findDoctorAll",
                dataType: "json",
                success: function (vo) {
                    let data = vo.list;
                    let bijiaozhi = "<option selected=\"selected\" value=\"" + data.id + "\">" + data.doctorName + "</option>"
                    let str = "";
                    for (let i = 0; i < data.length; i++) {
                        if (result == data[i].id) {
                            str += "<option selected='selected' value=\" " + data[i].id + "\">" + data[i].doctorName + "</option>\n"
                        } else {
                            str += "<option value=\" " + data[i].id + "\">" + data[i].doctorName + "</option>\n"
                        }

                    }
                    $("#doctorId").html(str);

                },
            })

        }

        $(function () {
            $.ajax({
                type: "GET",
                url: "/HMC/findByID",
                data: {"id": oneValues()},
                dataType: "json",
                success: function (vo) {
                    let data = vo.obj;
                    $("#hosR_id").val(data.id);
                    $("#hosR_name").val(data.registerName);
                    $("#hosR_idCar").val(data.idNumber);
                    $("#hosR_medical").val(data.medicalNumber);
                    $("#hosR_phone").val(data.phone);
                    data.selfPrice == 1 ? $("#d2").prop('checked', true) : $("#d1").prop('checked', true);
                    data.sex == 1 ? $("#s1").prop('checked', true) : $("#s0").prop('checked', true);
                    $("#hosR_age").val(data.age);
                    data.lookDoctor == 0 ? $("#c1").prop('checked', true) : $("#c2").prop('checked', true);
                    // $("#dept").html('<option>'+data.dept.deptName+'</option>')
                    findDept(data.department);
                    $("#dept").find("option[value = '" + data.dept.deptName + "']").attr("selected", "selected");
                    findDoctor(data.doctorId)
                    $("#doctorId").find("option[value = '" + data.doctorId + "']").attr("selected", "selected");
                    $("#hosR_remark").val(data.note);
                    $("#beH_nursePeople").val(data.hospital.nursePeople);
                    $("#beH_patBed").val(data.hospital.bedNumber);
                    $("#beH_illness").val(data.hospital.illness);
                }
            })
        })
    </script>
    <script type="text/javascript">
        $(function () {
            $('#backid').click(function () {
                window.location.href = "index.html";
            });
        });

        function update() {
            $.ajax({
                url: "/HMC/update",
                type: "POST",
                dataType: 'json',
                data: $('#updateForm').serialize(),
                error: function (request) {

                    alert("添加失败");
                },
                success: function (data) {
                    //接收后台返回的结果
                    alert("添加成功");
                    window.location.href="index.html";
                }
            });

        }
    </script>
    </script>
</head>
<body>
<form id="updateForm" class="definewidth m20">
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">病历号</td>
            <td><input type="text" id="hosR_id" name="hosR_id"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">姓名</td>
            <td><input type="text" id="hosR_name" name="hosR_name"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">证件类型</td>
            <td>身份证</td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">证件号</td>
            <td><input type="text" id="hosR_idCar" name="hosR_idCar"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">社保号</td>
            <td><input type="text" name="hosR_medical" id="hosR_medical"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">联系电话</td>
            <td><input type="text" id="hosR_phone" name="hosR_phone"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">是否自费</td>
            <td>
                <input type="radio" name="hosR_selfPrice" id="d1" value="0"/>否&nbsp;&nbsp;&nbsp;
                <input type="radio" name="hosR_selfPrice" id="d2" value="1"/>是
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">性别</td>
            <td>
                <input type="radio" name="hosR_sex" id="s1" value="1"/>男&nbsp;&nbsp;&nbsp;
                <input type="radio" name="hosR_sex" id="s0" value="0"/>女
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">年龄</td>
            <td><input type="text" id="hosR_age" name="hosR_age"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">初复诊</td>
            <td>
                <input type="radio" name="hosR_lookDoctor" id="c1" value="0"/>初诊&nbsp;&nbsp;&nbsp;
                <input type="radio" name="hosR_lookDoctor" id="c2" value="1"/>复诊
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">所挂科室</td>
            <td>
                <select id="dept" name="dept">
                </select>
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">指定医生</td>
            <td>
                <select id="doctorId" name="doctorId">

                </select>
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">备注</td>
            <td><input type="text" id="hosR_remark" name="hosR_remark"></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">护理</td>
            <td><input type="text" name="beH_nursePeople" id="beH_nursePeople" value="王小丫"/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">床位号</td>
            <td><input type="text" id="beH_patBed" name="beH_patBed" value="468"/></td>
        </tr>

        <tr>
            <td width="10%" class="tableleft">病情</td>
            <td><textarea id="beH_illness" name="beH_illness"></textarea></td>
        </tr>
        <tr>
            <td colspan="2">
                <center>
                    <input type="button" class="btn btn-primary" value="保存" onclick="update()">
                    &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
                </center>
            </td>
        </tr>
    </table>
</form>
</body>
</html>